package com.wen.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wen.common.Result;
import com.wen.entity.CoachRelation;
import com.wen.entity.Equipment;
import com.wen.mapper.CoachRelationMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 教练和课程的关系表
 */
@RestController
@RequestMapping("/coachrelation")
public class CoachRelationController {
    @Resource
    CoachRelationMapper coachRelationMapper;

    //    添加设备信息
    @PostMapping
    public Result<?> save(@RequestBody CoachRelation coachRelation){
        coachRelationMapper.insert(coachRelation);
        return Result.success();
    }
    //    更新
    @PutMapping
    public Result<?> update(@RequestBody CoachRelation coachRelation){
        coachRelationMapper.updateById(coachRelation);
        return Result.success();
    }
    //    s删除
    @DeleteMapping("/{id}")
    public Result<?> delete(@PathVariable Long id){
        coachRelationMapper.deleteById(id);
        return Result.success();
    }
    //    查询
    @GetMapping
    public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
                              @RequestParam(defaultValue = "10") Integer pageSize){
        Page<CoachRelation> NewsPage = coachRelationMapper.selectPage(new Page<>(pageNum,pageSize),null);
        return Result.success(NewsPage);
    }
}
